//
//  EditInfoTableViewCell.m
//  QT
//
//  Created by 甘世清 on 2025/1/7.
//

#import "EditInfoTableViewCell.h"

@implementation EditInfoTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (void)SQ_Style:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
   
    [self.contentView addSubview:self.leftLabel];
    [self.leftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(15);
        make.left.equalTo(self.contentView).offset(16);
    }];
    [self.contentView addSubview:self.messageLabel];
    [self.messageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(15);
        make.left.equalTo(self.contentView).offset(100);
        make.right.equalTo(self.contentView.mas_right).offset(-30);
    }];
    UIView * lineView = [[UIView alloc]init];
    lineView.backgroundColor = SQHexColor(@"#000000", 0.2);
    [self.contentView addSubview:lineView];
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(16);
            make.right.equalTo(self.contentView);
            make.height.mas_equalTo(0.4);
            make.top.equalTo(self.messageLabel.mas_bottom).offset(15);
    }];
    
    self.rightImage = [[UIImageView alloc]init];
    self.rightImage.image = SQGetImage(@"youjiantou");
    [self.contentView addSubview:self.rightImage];
    [self.rightImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.leftLabel);
            make.size.mas_equalTo(16);
            make.right.equalTo(self.contentView.mas_right).offset(-10);
    }];
    
    self.FS_cellBottomView = lineView;
}
- (void)setModel:(EditInfoModel *)model{
    _model = model;
    self.leftLabel.text = model.leftString;
    self.messageLabel.text = model.rightString;
    self.rightImage.hidden = NO;
    if ([model.leftString isEqualToString:@"性别"]) {
        self.rightImage.hidden = YES;
    }
    if ([model.leftString isEqualToString:@"生日"]&&[model.rightString isNotEmpty]) {
        self.rightImage.hidden = YES;
    }
    if (![model.rightString isNotEmpty]) {
        [self.messageLabel mas_updateConstraints:^(MASConstraintMaker *make) {
            make.height.mas_equalTo(20);
        }];
    }
}
- (UILabel *)leftLabel{
    if (!_leftLabel) {
        _leftLabel = [[UILabel alloc]init];
        _leftLabel.font = FONT_MEDIUM(14);
        _leftLabel.textColor = SQColor666666;
    }
    return _leftLabel;
}
- (UILabel *)messageLabel{
    if (!_messageLabel) {
        _messageLabel = [[UILabel alloc]init];
        _messageLabel.font = FONT_MEDIUM(14);
        _messageLabel.textColor = SQColor333333;
        _messageLabel.numberOfLines = 0;
        _messageLabel.textAlignment = NSTextAlignmentRight;
    }
    return _messageLabel;
}
@end
